/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __122BEDCC_30F7_4F3A_8D1C_34EE6BCAE753__
#define __122BEDCC_30F7_4F3A_8D1C_34EE6BCAE753__

// DRIVER={MySQL ODBC 5.3 ANSI Driver};SERVER=192.168.80.131;PORT=3306;DATABASE=javadb;UID=root;PWD=root;CharSet=UTF8;

namespace xos_odbc
{

    /////////////////////////////////////////////////////////////////////////////////
    // 
    // 语句接口
    // 
    class i_stmt : public xos::i_release
    {
    public:
        enum enumDirection
        {
            DIRECT_INPUT_OUTPUT,
            DIRECT_OUTPUT,
            DIRECT_INPUT
        };

        enum enumValueType
        {
			VT_CHAR_ARRAY,
            VT_DOUBLE,
            VT_FLOAT,
            VT_BOOL,
            VT_BIN,
			VT_U64,
			VT_I64,
            VT_U32,
            VT_I32,
            VT_U16,
            VT_I16,
            VT_U8,
            VT_I8
        };

		enum enumLenOrPtr
		{
			LP_DEFAULT_PARAM = -5,
			LP_DATA_AT_EXEC = -2,
			LP_NULL_DATA = -1,
			LP_NTS = -3
		};

    protected:
        virtual ~i_stmt(){}

    public:
        // 
        // 查询结果集中的列数,index从0开始
        // 
        virtual int get_col_info( int nIndex, char * lpszName, int nLen, int & nType, int & nSize, int & nDigitNum, int & nCanNull ) = 0;
        virtual int get_affect_row_num( int & nNum ) = 0;
        virtual int get_row_num( int & nNum ) = 0;
        virtual int get_col_num( int & nNum ) = 0;

        // 
        // 直接运行sql
        // 
        //  0 : success. 
        //  1 : running. 
        // -1 : failed
        // 
        virtual int execute_direct( const char * lpszSql ) = 0;

        //
        // 编译sql
        // 
        //  0 : success. 
        //  1 : running. 
        // -1 : failed
        // 
        virtual int compile_sql( const char * lpszSql ) = 0;

        // 
        // 绑定输入后执行sql语句写入
        // 
        //  0 : success. 
        //  1 : running. 
        // -1 : failed
        // 
        virtual int execute() = 0;

        // 
        //  0 : success
        //  1 : pending
        //  2 : no data
        // -1 : failed
        // 
        virtual int fetch() = 0;
    };

} // xos_odbc

#endif // __122BEDCC_30F7_4F3A_8D1C_34EE6BCAE753__
